﻿<Window x:Class="OpenDynDnsChanger.AdminApp.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        Title="Open DynDNS Changer - Service Admin Panel" Height="350" Width="525"
        Loaded="Window_Loaded"
        
        xmlns:vm="clr-namespace:OpenDynDnsChanger.AdminApp.ViewModel"
        xmlns:cntrl="clr-namespace:OpenDynDnsChanger.AdminApp.Controls"
        
        >
    <Window.DataContext>
        <vm:MainViewModel />
    </Window.DataContext>
    
    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto" />
            <RowDefinition Height="*" />
        </Grid.RowDefinitions>
        
        <Menu>
            <MenuItem Header="File">
                <MenuItem Header="Exit" Command="{Binding Path=ExitCommand}" />
            </MenuItem>
        </Menu>
        
        <Grid Grid.Row="1">
            <Grid.RowDefinitions>
                <RowDefinition Height="60" />
                <RowDefinition Height="*" />
            </Grid.RowDefinitions>
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="*" />
                <ColumnDefinition Width="*" />
            </Grid.ColumnDefinitions>
            
            <GroupBox Header="Status" Grid.ColumnSpan="2">
                <Grid>
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="Auto" />
                        <ColumnDefinition Width="*" />
                    </Grid.ColumnDefinitions>
                    
                    <cntrl:ServiceStatusControl Controller="{Binding Path=CurrentController}" VerticalAlignment="Center" />
                    
                    <StackPanel Grid.Column="1" Orientation="Horizontal" HorizontalAlignment="Right">
                        <Button Command="{Binding Path=StartServiceCommand}" VerticalAlignment="Center" Content="Start" IsEnabled="{Binding Path=CanServiceStart}" Width="70" />
                        <Button Command="{Binding Path=StopServiceCommand}" VerticalAlignment="Center" Content="Stop" IsEnabled="{Binding Path=CanServiceStop}" Width="70" Margin="5,0,0,0" />
                    </StackPanel>
                    
                </Grid>
            </GroupBox>
            
            <GroupBox Header="Credentials" Grid.Row="1" Grid.Column="0">
                <Grid>
                    <Grid.RowDefinitions>
                        <RowDefinition Height="6" />
                        <RowDefinition Height="24" />
                        <RowDefinition Height="24" />
                        <RowDefinition Height="*" />
                    </Grid.RowDefinitions>
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="90" />
                        <ColumnDefinition Width="*" MinWidth="120" />
                    </Grid.ColumnDefinitions>
                    
                    <TextBlock Grid.Row="1" Text="Username: " />
                    <TextBox Grid.Row="1" Grid.Column="1" Text="{Binding Path=Username, Mode=TwoWay}" />

                    <TextBlock Grid.Row="2" Text="Password: " />
                    <PasswordBox Loaded="pb_CredentialPW_Loaded" Grid.Row="2" Grid.Column="1" x:Name="pb_CredentialPW" />


                    <Button Grid.Column="1" Grid.Row="3" VerticalAlignment="Bottom" Width="70" HorizontalAlignment="Right" Content="Save" Command="{Binding Path=SaveCredentialsCommand}" CommandParameter="{Binding ElementName=pb_CredentialPW}"  />
                    
                </Grid>
            </GroupBox>
            
            <GroupBox Grid.Row="1" Grid.Column="1" Header="General">
                <Grid>
                    <Grid.RowDefinitions>
                        <RowDefinition Height="6" />
                        <RowDefinition Height="24" />
                        <RowDefinition Height="24" />
                        <RowDefinition Height="*" />
                    </Grid.RowDefinitions>
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="90" />
                        <ColumnDefinition Width="*" MinWidth="120" />
                    </Grid.ColumnDefinitions>
                    
                    <TextBlock Grid.Row="1" Text="Update Time: " />
                    <Slider Grid.Row="1" Grid.Column="1" Value="{Binding Path=UpdateTime, Mode=TwoWay}" Minimum="5000" Maximum="86400000" SmallChange="5000" LargeChange="100000" />
                    <StackPanel Grid.Row="2" Grid.Column="1" HorizontalAlignment="Right" Orientation="Horizontal">
                        <TextBlock Text="{Binding Path=UpdateTime}" />
                        <TextBlock Text="ms" />
                    </StackPanel>

                    <Button Grid.Column="1" Grid.Row="3" VerticalAlignment="Bottom" Width="70" HorizontalAlignment="Right" Content="Save" Command="{Binding Path=SaveConfigurationCommand}" CommandParameter="{Binding ElementName=pb_CredentialPW}"  />

                </Grid>
            </GroupBox>
            
        </Grid>
        
    </Grid>
</Window>
